package com.hs.mobile.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;

import com.hs.mobile.model.Register;
import com.hs.mobile.service.register.RegisterService;

@Controller
public class RegisterController {

	@Resource(name="registerService")
	private RegisterService resgiterService;
	
	@Autowired
	public RegisterController( RegisterService registerService )
	{
		this.resgiterService = registerService;
	}
	
	@GET
	@RequestMapping(value="/register/{id}", method = RequestMethod.GET)
	@Produces(MediaType.APPLICATION_JSON)
	public @ResponseBody Register getRegister(@PathVariable("id") Long id )
	{
		return resgiterService.findRegisterById(id);
	}
	
	@GET
	@RequestMapping(value="/registers", method = RequestMethod.GET)
	@Produces(MediaType.APPLICATION_JSON)
	public @ResponseBody List<Register> getRegister()
	{
		return resgiterService.getAllRegisters();
	}
}
